package math;

public class BigNumSub {
    public String bigNumSub(StringBuilder big, StringBuilder small) {
        StringBuilder result = new StringBuilder();
        big = big.reverse();
        small = small.reverse();
        int jinwei = 0;
        for (int i = 0; i < big.length(); i++) {
            int s = i >= small.length() ? 0 : small.charAt(i) - '0';
            int num = big.charAt(i) - '0' - s - jinwei;
            if (num < 0) {
                num += 10;
                jinwei = 1;
            } else {
                jinwei = 0;
            }
            result.append(((char) (num + '0')));
        }

        while (result.charAt(result.length() - 1) == '0') {
            result.deleteCharAt(result.length() - 1);
        }
        return result.reverse().toString();

    }
}
